//
//  JHSUsersDetailHeaderView.m
//  LogIn(登录)
//
//  Created by chenWei on 2017/3/23.
//  Copyright © 2017年 陈伟. All rights reserved.
//

#import "JHSUsersDetailHeaderView.h"
#import "JHSUserinfoModel.h"
@interface JHSUsersDetailHeaderView ()

@end

@implementation JHSUsersDetailHeaderView{
    //用户详细信息列表
    NSArray *arr;
    //解档信息
    NSDictionary* dict;
}
-(void)viewDidLoad{
    [super viewDidLoad];
    arr = @[@"姓名",@"年龄",@"性别",@"身高",@"体重",@"籍贯",@"常居地",@"联系方式",@"证件号码"];
    //        NSDictionary* UserDic = @{@"姓名":@"true_name",@"年龄":@"age",@"性别":@"gender",@"身高":@"height",@"体重":@"weight",@"籍贯":@"address",@"常居地":@"",@"联系方式":@"mobile_number",@"证件号码":@"card_number"};
    [self loadData];
    [self setupUI];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self setupUI];
    
    
}

- (void)setupUI
{

    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    //注册
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
}



#pragma mark - 数据源方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 9;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text = indexPath.description;
    cell.textLabel.text = arr[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    switch (indexPath.row) {
        case 0:
            cell.detailTextLabel.text = _model.true_name;
            
            break;
        case 1:
              cell.detailTextLabel.text = [NSString stringWithFormat:@"%zd",_model.age];
            break;
        case 2:
              cell.detailTextLabel.text =  [NSString stringWithFormat:@"%zd",_model.gender];
            break;
        case 3:
              cell.detailTextLabel.text = [NSString stringWithFormat:@"%zd",_model.height];
            break;
        case 4:
              cell.detailTextLabel.text =  [NSString stringWithFormat:@"%zd",_model.height];
            break;
        case 5:
              cell.detailTextLabel.text = _model.true_name;
            break;
        case 6:
              cell.detailTextLabel.text = _model.true_name;
            break;
        case 7:
              cell.detailTextLabel.text = _model.true_name;
            break;
        case 8:
              cell.detailTextLabel.text = _model.true_name;
            break;
        default:
            break;
    }
      
    return cell;
}

#pragma mark - 加载数据
-(void)loadData{
    //解档
    NSString *filePath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
    filePath = [filePath stringByAppendingPathComponent:@"userInfo.plist"];
    dict = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
    
    NSLog(@"%@",filePath);
    
    //字典转模型
        JHSUserinfoModel *model = [JHSUserinfoModel yy_modelWithDictionary:dict];
    _model = model;
    [self.tableView reloadData];
}


@end
